package cn.edu.sjtu.se.dslab.component.data;

import java.io.Serializable;

import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.Table;

import cn.edu.sjtu.se.dslab.component.method.MethodComponent;

@Entity
@Table(name = "upload_file")
public class UploadFile implements Serializable {

	public static final String TYPE_HEAD = "头文件";
	
	public static final String TYPE_SRC = "源文件";
	
	/**
	 * 
	 */
	private static final long serialVersionUID = -1553973699521543387L;
	
	private long id;
	
	private String path;
	
	private MethodComponent component;
	
	private String type;
	
	private String name;
	
	private String uri;

	@Id
	@GeneratedValue(strategy = GenerationType.AUTO)
	public long getId() {
		return id;
	}

	public void setId(long id) {
		this.id = id;
	}
	@Column(name = "file_path", nullable = true, length = 255)
	public String getPath() {
		return path;
	}

	public void setPath(String path) {
		this.path = path;
	}
	@ManyToOne(cascade = { CascadeType.REFRESH })
	@JoinColumn(name = "component_id")
	public MethodComponent getComponent() {
		return component;
	}

	public void setComponent(MethodComponent component) {
		this.component = component;
	}
	
	@Column(name = "type", nullable = true, length = 255)
	public String getType() {
		return type;
	}

	public void setType(String type) {
		this.type = type;
	}
	@Column(name = "name", nullable = true, length = 255)
	public String getName() {
		return name;
	}

	public void setName(String name) {
		this.name = name;
	}
	@Column(name = "uri", nullable = true, length = 255)
	public String getUri() {
		return uri;
	}

	public void setUri(String uri) {
		this.uri = uri;
	}
	
	public UploadFile(String path, String type, String name) {
		super();
		this.path = path;
		this.type = type;
		this.name = name;
	}
	
	public UploadFile() {
		super();
	}
}
